<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,IE=9,chrome=1"><meta name="generator" content="MATLAB R2018b"><title>Untitled</title><style type="text/css">.rtcContent { padding: 30px; } .S0 { margin: 3px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: rgb(60, 60, 60); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: center;  }
.S1 { margin: 20px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: rgb(60, 60, 60); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;  }
.S2 { margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: normal; text-align: left;  }
.CodeBlock { background-color: #F7F7F7; margin: 10px 0 10px 0;}
.S3 { border-left: 0.578703701496124px solid rgb(233, 233, 233); border-right: 0.578703701496124px solid rgb(233, 233, 233); border-top: 0.578703701496124px solid rgb(233, 233, 233); border-bottom: 0px none rgb(0, 0, 0); border-radius: 4px 4px 0px 0px; padding: 6px 45px 0px 13px; line-height: 17.234001159668px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;  }
.S4 { border-left: 0.578703701496124px solid rgb(233, 233, 233); border-right: 0.578703701496124px solid rgb(233, 233, 233); border-top: 0px none rgb(0, 0, 0); border-bottom: 0px none rgb(0, 0, 0); border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 17.234001159668px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;  }
.S5 { border-left: 0.578703701496124px solid rgb(233, 233, 233); border-right: 0.578703701496124px solid rgb(233, 233, 233); border-top: 0px none rgb(0, 0, 0); border-bottom: 0.578703701496124px solid rgb(233, 233, 233); border-radius: 0px; padding: 0px 45px 4px 13px; line-height: 17.234001159668px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;  }
.S6 { color: rgb(64, 64, 64); padding: 10px 0px 6px 17px; background: rgb(255, 255, 255) none repeat scroll 0% 0% / auto padding-box border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px; overflow-x: hidden; line-height: 17.234001159668px;  }
.S7 { border-left: 0.578703701496124px solid rgb(233, 233, 233); border-right: 0.578703701496124px solid rgb(233, 233, 233); border-top: 0.578703701496124px solid rgb(233, 233, 233); border-bottom: 0.578703701496124px solid rgb(233, 233, 233); border-radius: 0px; padding: 6px 45px 4px 13px; line-height: 17.234001159668px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;  }
.S8 { border-left: 0.578703701496124px solid rgb(233, 233, 233); border-right: 0.578703701496124px solid rgb(233, 233, 233); border-top: 0.578703701496124px solid rgb(233, 233, 233); border-bottom: 0px none rgb(0, 0, 0); border-radius: 0px; padding: 6px 45px 0px 13px; line-height: 17.234001159668px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;  }
.S9 { margin: 10px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: normal; text-align: left;  }
.S10 { border-left: 0.578703701496124px solid rgb(233, 233, 233); border-right: 0.578703701496124px solid rgb(233, 233, 233); border-top: 0.578703701496124px solid rgb(233, 233, 233); border-bottom: 0.578703701496124px solid rgb(233, 233, 233); border-radius: 4px 4px 0px 0px; padding: 6px 45px 4px 13px; line-height: 17.234001159668px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;  }
.S11 { border-left: 0.578703701496124px solid rgb(233, 233, 233); border-right: 0.578703701496124px solid rgb(233, 233, 233); border-top: 0.578703701496124px solid rgb(233, 233, 233); border-bottom: 0.578703701496124px solid rgb(233, 233, 233); border-radius: 0px 0px 4px 4px; padding: 6px 45px 4px 13px; line-height: 17.234001159668px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;  }
.S12 { border-left: 0.578703701496124px solid rgb(233, 233, 233); border-right: 0.578703701496124px solid rgb(233, 233, 233); border-top: 0px none rgb(0, 0, 0); border-bottom: 0.578703701496124px solid rgb(233, 233, 233); border-radius: 0px 0px 4px 4px; padding: 0px 45px 4px 13px; line-height: 17.234001159668px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;  }</style></head><body><div class = rtcContent><h2  class = 'S0'></h2><h2  class = 'S1'><span>Axially loaded bar: The Finite Element Solution</span></h2><div  class = 'S2'><span style=' font-weight: bold;'></span></div><div  class = 'S2'><span style=' font-weight: bold;'>Discretization</span></div><div  class = 'S2'><span>The first step in the finite element approach is to divide the domain into</span><span> </span><span style=' font-weight: bold;'>elements</span><span> </span><span>and</span><span> </span><span style=' font-weight: bold;'>nodes</span><span>, i.e., to create the</span><span> </span><span style=' font-weight: bold;'>finite element mesh</span><span>.</span></div><div  class = 'S2'><span>Let us consider a simple situation and divide the rod into 3 elements and 4 nodes as shown in the next figure.</span></div><div  class = 'S2'><img src = "" width = "312" height = "289" alt = "" style = "vertical-align: baseline"></img></div><div  class = 'S2'><span>Figure 1. Finite element mesh and basis functions for the bar.			</span></div><div  class = 'S2'><span>					</span></div><div  class = 'S2'><span>The mathematical concept of bar finite elements is based on </span><span style=' font-style: italic;'>approximation </span><span>of the axial displacement </span><span style=' font-style: italic;'>u</span><span>(</span><span style=' font-style: italic;'>x</span><span>) </span><span>over the element. The exact displacement </span><span style=' font-style: italic;'>u</span><span>∗ </span><span>is replaced by an approximate displacement </span></div><div  class = 'S2'><span style="vertical-align:-5px"><img src="" width="84.5" height="18.5" /></span></div><div  class = 'S2'><span>			</span></div><h2  class = 'S1'><span>Shape functions </span></h2><div  class = 'S2'><span>The functions </span><span style="vertical-align:-6px"><img src="" width="15" height="19.5" /></span><span>have special characteristics in finite element methods and are generally written as </span><span style="vertical-align:-6px"><img src="" width="16" height="19.5" /></span><span> and are called '''basis functions''', ''' shape functions''', or ''' interpolation functions'''.</span></div><div  class = 'S2'><span>In a two-node bar element the only possible variation of the displacement ue that satisfies the interelement continuity requirement stated above is linear. It can be expressed by the interpolation formula </span><span style="vertical-align:-5px"><img src="" width="15" height="18.5" /></span><span> = </span><span style="vertical-align:-6px"><img src="" width="241.5" height="20.5" /></span><span> </span></div><div  class = 'S2'><span> 2 special cases on the BCs...</span></div><div  class = 'S2'><img src = "" width = "176" height = "180" alt = "" style = "vertical-align: baseline"></img></div><div  class = 'S2'><span>in the element space e we can write (x/l often called zeta)</span></div><div  class = 'S2'><span>We replace hand computing with symbolic computing</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S3'><span style="white-space: pre;"><span>syms </span><span style="color: rgb(160, 32, 240);">x l real</span></span></div></div><div class="inlineWrapper"><div  class = 'S4'><span style="white-space: pre;"><span>syms </span><span style="color: rgb(160, 32, 240);">E A real</span></span></div></div><div class="inlineWrapper"><div  class = 'S4'><span style="white-space: pre;"><span>syms </span><span style="color: rgb(160, 32, 240);">u_1 u_2 real</span></span></div></div><div class="inlineWrapper"><div  class = 'S4'></div></div><div class="inlineWrapper outputs"><div  class = 'S5'><span style="white-space: pre;"><span>N_1=1-x/l</span></span></div><div  class = 'S6'><div class="inlineElement eoOutputWrapper embeddedOutputsSymbolicElement" uid="438E3F9F" data-testid="output_0" data-width="283" data-height="62" data-hashorizontaloverflow="false" style="width: 312px; max-height: 261px;"><div class="symbolicElement"><div class="embeddedOutputsVariableElement">N_1 =&nbsp;</div><span class="MathEquation displaySymbolicElement" style="font-size: 15px;"><span style="vertical-align: -15px;"><img src="" width="35" height="34"></span></span></div></div></div></div><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: pre;"><span>N_2=x/l</span></span></div><div  class = 'S6'><div class="inlineElement eoOutputWrapper embeddedOutputsSymbolicElement" uid="8BFEA136" data-testid="output_1" data-width="283" data-height="62" data-hashorizontaloverflow="false" style="width: 312px; max-height: 261px;"><div class="symbolicElement"><div class="embeddedOutputsVariableElement">N_2 =&nbsp;</div><span class="MathEquation displaySymbolicElement" style="font-size: 15px;"><span style="vertical-align: -15px;"><img src="" width="10.5" height="34"></span></span></div></div></div></div><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: pre;"><span>N= [ N_1 N_2]</span></span></div><div  class = 'S6'><div class="inlineElement eoOutputWrapper embeddedOutputsSymbolicElement" uid="6092BA98" data-testid="output_2" data-width="283" data-height="63" data-hashorizontaloverflow="false" style="width: 312px; max-height: 261px;"><div class="symbolicElement"><div class="embeddedOutputsVariableElement">N =&nbsp;</div><span class="MathEquation displaySymbolicElement" style="font-size: 15px;"><span style="vertical-align: -15px;"><img src="" width="72" height="36"></span></span></div></div></div></div><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: pre;"><span>U= [u_1 u_2]</span></span></div><div  class = 'S6'><div class="inlineElement eoOutputWrapper embeddedOutputsSymbolicElement" uid="3DB1BAAE" data-testid="output_3" data-width="283" data-height="30" data-hashorizontaloverflow="false" style="width: 312px; max-height: 261px;"><div class="symbolicElement"><span class="embeddedOutputsVariableElement">U =&nbsp;</span><span class="MathEquation inlineSymbolicElement" style="font-size: 15px;"><span style="vertical-align: -7px;"><img src="" width="53.5" height="20.5"></span></span></div></div></div></div><div class="inlineWrapper"><div  class = 'S8'></div></div><div class="inlineWrapper outputs"><div  class = 'S5'><span style="white-space: pre;"><span>ue=N*U'</span></span></div><div  class = 'S6'><div class="inlineElement eoOutputWrapper embeddedOutputsSymbolicElement" uid="E39FC014" data-testid="output_4" data-width="283" data-height="65" data-hashorizontaloverflow="false" style="width: 312px; max-height: 261px;"><div class="symbolicElement"><div class="embeddedOutputsVariableElement">ue =&nbsp;</div><span class="MathEquation displaySymbolicElement" style="font-size: 15px;"><span style="vertical-align: -15px;"><img src="" width="110.5" height="37.5"></span></span></div></div></div></div></div><div  class = 'S9'><span>				</span></div><h2  class = 'S1'><span style=' font-weight: bold;'>The Strain-Displacement Equation</span></h2><div  class = 'S2'><span style=' font-weight: bold;'> </span><span>The axial strain over the element is given by</span></div><div  class = 'S2'><span> </span><span style="vertical-align:-15px"><img src="" width="48.5" height="34.5" /></span><span> </span><span style="vertical-align:-15px"><img src="" width="255.5" height="37.5" /></span><span> </span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S10'><span style="white-space: pre;"><span>B=diff(N,x)</span></span></div><div  class = 'S6'><div class="inlineElement eoOutputWrapper embeddedOutputsSymbolicElement" uid="9957A8E0" data-testid="output_5" data-width="283" data-height="63" data-hashorizontaloverflow="false" style="width: 312px; max-height: 261px;"><div class="symbolicElement"><div class="embeddedOutputsVariableElement">B =&nbsp;</div><span class="MathEquation displaySymbolicElement" style="font-size: 15px;"><span style="vertical-align: -15px;"><img src="" width="60.5" height="36"></span></span></div></div></div></div><div class="inlineWrapper"><div  class = 'S11'><span style="white-space: pre;"><span style="color: rgb(34, 139, 34);">%B = [-1/h 1/h]; %with l=h step of discretization</span></span></div></div></div><div  class = 'S9'><span>B is called the </span><span style=' font-style: italic;'>strain-displacement </span><span>matrix. 	 </span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S10'><span style="white-space: pre;"><span>epsilon=B*U'</span></span></div><div  class = 'S6'><div class="inlineElement eoOutputWrapper embeddedOutputsSymbolicElement" uid="A4DD516B" data-testid="output_6" data-width="283" data-height="64" data-hashorizontaloverflow="false" style="width: 312px; max-height: 261px;"><div class="symbolicElement"><div class="embeddedOutputsVariableElement">epsilon =&nbsp;</div><span class="MathEquation displaySymbolicElement" style="font-size: 15px;"><span style="vertical-align: -15px;"><img src="" width="45" height="36.5"></span></span></div></div></div></div><div class="inlineWrapper"><div  class = 'S11'><span style="white-space: pre;"><span style="color: rgb(34, 139, 34);">%</span></span></div></div></div><div  class = 'S9'><span>How can I get the stiffness matrix ???</span></div><div  class = 'S2'><img src = "" width = "505" height = "355" alt = "" style = "vertical-align: baseline"></img></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S3'><span style="white-space: pre;"><span>syms </span><span style="color: rgb(160, 32, 240);">zeta real</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S5'><span style="white-space: pre;"><span>Ke=E*A*</span><span class="warning_squiggle_rte">B</span><span>'*B*int(l,zeta,[0 1])</span></span></div><div  class = 'S6'><div class="inlineElement eoOutputWrapper embeddedOutputsSymbolicElement" uid="C5FDB054" data-testid="output_7" data-width="283" data-height="102" data-hashorizontaloverflow="false" style="width: 312px; max-height: 261px;"><div class="symbolicElement"><div class="embeddedOutputsVariableElement">Ke =&nbsp;</div><span class="MathEquation displaySymbolicElement" style="font-size: 15px;"><span style="vertical-align: -32px;"><img src="" width="112" height="74.5"></span></span></div></div></div></div><div class="inlineWrapper"><div  class = 'S11'><span style="white-space: pre;"><span style="color: rgb(34, 139, 34);">% Ke = (A*E/h)*[[1 -1];[-1 1]];  %with l=h step of discretization</span></span></div></div></div><h2  class = 'S1'><img src = "" width = "605" height = "190" alt = "" style = "vertical-align: baseline"></img></h2><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S3'><span style="white-space: pre;"><span>syms </span><span style="color: rgb(160, 32, 240);">q a zeta x_1 x_2 real</span></span></div></div><div class="inlineWrapper"><div  class = 'S4'></div></div><div class="inlineWrapper outputs"><div  class = 'S5'><span style="white-space: pre;"><span>Nzeta=[1-zeta zeta]</span></span></div><div  class = 'S6'><div class="inlineElement eoOutputWrapper embeddedOutputsSymbolicElement" uid="A2001F9D" data-testid="output_8" data-width="283" data-height="27" data-hashorizontaloverflow="false" style="width: 312px; max-height: 261px;"><div class="symbolicElement"><span class="embeddedOutputsVariableElement">Nzeta =&nbsp;</span><span class="MathEquation inlineSymbolicElement" style="font-size: 15px;"><span style="vertical-align: -5px;"><img src="" width="67.5" height="18"></span></span></div></div></div></div><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: pre;"><span class="warning_squiggle_rte">fe</span><span>=int(q*Nzeta'*l,zeta,[0 1])</span></span></div><div  class = 'S6'><div class="inlineElement eoOutputWrapper embeddedOutputsSymbolicElement" uid="8087E138" data-testid="output_9" data-width="283" data-height="102" data-hashorizontaloverflow="false" style="width: 312px; max-height: 261px;"><div class="symbolicElement"><div class="embeddedOutputsVariableElement">fe =&nbsp;</div><span class="MathEquation displaySymbolicElement" style="font-size: 15px;"><span style="vertical-align: -32px;"><img src="" width="43.5" height="74.5"></span></span></div></div></div></div></div><div  class = 'S9'><img src = "" width = "167" height = "106" alt = "" style = "vertical-align: baseline"></img></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S10'><span style="white-space: pre;"><span>Nzeta=[(x_2-x)/l (x-x_1)/l]</span></span></div><div  class = 'S6'><div class="inlineElement eoOutputWrapper embeddedOutputsSymbolicElement" uid="47D253AB" data-testid="output_10" data-width="283" data-height="66" data-hashorizontaloverflow="false" style="width: 312px; max-height: 261px;"><div class="symbolicElement"><div class="embeddedOutputsVariableElement">Nzeta =&nbsp;</div><span class="MathEquation displaySymbolicElement" style="font-size: 15px;"><span style="vertical-align: -15px;"><img src="" width="122" height="39"></span></span></div></div></div></div><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: pre;"><span>q=a*x</span></span></div><div  class = 'S6'><div class="inlineElement eoOutputWrapper embeddedOutputsSymbolicElement" uid="9596BEEB" data-testid="output_11" data-width="283" data-height="27" data-hashorizontaloverflow="false" style="width: 312px; max-height: 261px;"><div class="symbolicElement"><span class="embeddedOutputsVariableElement">q =&nbsp;</span><span class="MathEquation inlineSymbolicElement" style="font-size: 15px;"><span style="vertical-align: -5px;"><img src="" width="21" height="18"></span></span></div></div></div></div><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: pre;"><span>q*Nzeta'</span><span style="color: rgb(34, 139, 34);">%</span></span></div><div  class = 'S6'><div class="inlineElement eoOutputWrapper embeddedOutputsSymbolicElement" uid="7B427A83" data-testid="output_12" data-width="283" data-height="108" data-hashorizontaloverflow="false" style="width: 312px; max-height: 261px;"><div class="symbolicElement"><div class="embeddedOutputsVariableElement">ans =&nbsp;</div><span class="MathEquation displaySymbolicElement" style="font-size: 15px;"><span style="vertical-align: -35px;"><img src="" width="113" height="80"></span></span></div></div></div></div><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: pre;"><span class="warning_squiggle_rte">fe</span><span>= int(q*Nzeta',x,[x_1 x_2])</span></span></div><div  class = 'S6'><div class="inlineElement eoOutputWrapper embeddedOutputsSymbolicElement" uid="1B641709" data-testid="output_13" data-width="283" data-height="110" data-hashorizontaloverflow="false" style="width: 312px; max-height: 261px;"><div class="symbolicElement"><div class="embeddedOutputsVariableElement">fe =&nbsp;</div><span class="MathEquation displaySymbolicElement" style="font-size: 15px;"><span style="vertical-align: -36px;"><img src="" width="167" height="82"></span></span></div></div></div></div><div class="inlineWrapper"><div  class = 'S8'></div></div><div class="inlineWrapper outputs"><div  class = 'S5'><span style="white-space: pre;"><span>fe=expand(simplifyFraction(int(q*Nzeta',x,[x_1 x_2])))</span></span></div><div  class = 'S6'><div class="inlineElement eoOutputWrapper embeddedOutputsSymbolicElement" uid="D72F195E" data-testid="output_14" data-width="283" data-height="110" data-hashorizontaloverflow="false" style="width: 312px; max-height: 261px;"><div class="symbolicElement"><div class="embeddedOutputsVariableElement">fe =&nbsp;</div><span class="MathEquation displaySymbolicElement" style="font-size: 15px;"><span style="vertical-align: -36px;"><img src="" width="159" height="82"></span></span></div></div></div></div><div class="inlineWrapper"><div  class = 'S8'><span style="white-space: pre;"><span style="color: rgb(34, 139, 34);">%fe1 = a*x2/(2*h)*(x2^2-x1^2) - a/(3*h)*(x2^3-x1^3);</span></span></div></div><div class="inlineWrapper"><div  class = 'S4'><span style="white-space: pre;"><span style="color: rgb(34, 139, 34);">%fe1 = 1/(6*h)*( 3a*x2*(x2^2-x1^2) - 2*a*(x2^3-x1^3) );</span></span></div></div><div class="inlineWrapper"><div  class = 'S4'><span style="white-space: pre;"><span style="color: rgb(34, 139, 34);">%fe1 = 1/(6*h)*( 3a*x2^3 -3*a*x2*x1^2 - 2*a*x2^3 +2*a*x1^3 );</span></span></div></div><div class="inlineWrapper"><div  class = 'S4'><span style="white-space: pre;"><span style="color: rgb(34, 139, 34);">%fe1 = 1/(6*h)*( a*x2^3 -3*a*x2*x1^2 +2*a*x1^3 );</span></span></div></div><div class="inlineWrapper"><div  class = 'S4'><span style="white-space: pre;"><span style="color: rgb(34, 139, 34);">%fe2 = -a*x1/(2*h)*(x2^2-x1^2) + a/(3*h)*(x2^3-x1^3);</span></span></div></div><div class="inlineWrapper"><div  class = 'S4'><span style="white-space: pre;"><span style="color: rgb(34, 139, 34);">%fe2 = 1/(6*h)*(-3*a*x1*(x2^2-x1^2) + 2*a*(x2^3-x1^3));</span></span></div></div><div class="inlineWrapper"><div  class = 'S4'><span style="white-space: pre;"><span style="color: rgb(34, 139, 34);">%fe2 = 1/(6*h)*( -3*a*x1*x2^2 +1*a*x1^3 + 2*a*x2^3 );</span></span></div></div><div class="inlineWrapper"><div  class = 'S12'><span style="white-space: pre;"><span style="color: rgb(34, 139, 34);">%  fe = [fe1;fe2];</span></span></div></div></div><h2  class = 'S1'></h2></div><br>
<!-- 
##### SOURCE BEGIN #####
%% 
%% Axially loaded bar: The Finite Element Solution
% **
% 
% *Discretization*
% 
% The first step in the finite element approach is to divide the domain into 
% *elements* and *nodes*, i.e., to create the *finite element mesh*.
% 
% Let us consider a simple situation and divide the rod into 3 elements and 
% 4 nodes as shown in the next figure.
% 
% 
% 
% Figure 1. Finite element mesh and basis functions for the bar.			
% 
% 					
% 
% The mathematical concept of bar finite elements is based on _approximation 
% _of the axial displacement _u_(_x_) over the element. The exact displacement 
% _u_∗ is replaced by an approximate displacement 
% 
% $$u^{*}(x)=u^{e}(x)$$
% 
% 			
%% Shape functions 
% The functions $\varphi_i$have special characteristics in finite element methods 
% and are generally written as $N_i$ and are called '''basis functions''', ''' 
% shape functions''', or ''' interpolation functions'''.
% 
% In a two-node bar element the only possible variation of the displacement 
% ue that satisfies the interelement continuity requirement stated above is linear. 
% It can be expressed by the interpolation formula $u^{e}$ = $N_1 u_1 +N_2 u_2 
% = [ N_1\:N_2 ] [u_1\: u_2]^T = N*u^T$ 
% 
%  2 special cases on the BCs...
% 
% 
% 
% in the element space e we can write (x/l often called zeta)
% 
% We replace hand computing with symbolic computing

syms x l real
syms E A real
syms u_1 u_2 real

N_1=1-x/l
N_2=x/l
N= [ N_1 N_2]
U= [u_1 u_2]

ue=N*U'
%% 
% 				
%% *The Strain-Displacement Equation*
% * *The axial strain over the element is given by
% 
% $$\epsilon=\frac{du^{e}}{dx}$$ $$= [ \frac{dN_1}{dx}\:\frac{dN_2}{dx}\ 
% ] [u_1\: u_2]^T =\frac{dN}{dx}*u^T = B*u^T $$ 

B=diff(N,x)
%B = [-1/h 1/h]; %with l=h step of discretization
%% 
% B is called the _strain-displacement _matrix. 	 

epsilon=B*U'
%
%% 
% How can I get the stiffness matrix ???
% 
% 

syms zeta real
Ke=E*A*B'*B*int(l,zeta,[0 1])
% Ke = (A*E/h)*[[1 -1];[-1 1]];  %with l=h step of discretization
%% 

syms q a zeta x_1 x_2 real

Nzeta=[1-zeta zeta]
fe=int(q*Nzeta'*l,zeta,[0 1])
%% 
% 

Nzeta=[(x_2-x)/l (x-x_1)/l]
q=a*x
q*Nzeta'%
fe= int(q*Nzeta',x,[x_1 x_2])

fe=expand(simplifyFraction(int(q*Nzeta',x,[x_1 x_2])))
%fe1 = a*x2/(2*h)*(x2^2-x1^2) - a/(3*h)*(x2^3-x1^3);
%fe1 = 1/(6*h)*( 3a*x2*(x2^2-x1^2) - 2*a*(x2^3-x1^3) );
%fe1 = 1/(6*h)*( 3a*x2^3 -3*a*x2*x1^2 - 2*a*x2^3 +2*a*x1^3 );
%fe1 = 1/(6*h)*( a*x2^3 -3*a*x2*x1^2 +2*a*x1^3 );
%fe2 = -a*x1/(2*h)*(x2^2-x1^2) + a/(3*h)*(x2^3-x1^3);
%fe2 = 1/(6*h)*(-3*a*x1*(x2^2-x1^2) + 2*a*(x2^3-x1^3));
%fe2 = 1/(6*h)*( -3*a*x1*x2^2 +1*a*x1^3 + 2*a*x2^3 );
%  fe = [fe1;fe2];
%%
##### SOURCE END #####
--></body></html>